home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: miker3@ix.netcom.com (Mike Rubenstein)
- Newsgroups: comp.lang.c++,comp.lang.c,comp.lang
- Subject: Re: Undefined behavior? on type conversion, was: Re: Hungarian notation
- Date: Fri, 09 Feb 1996 01:10:30 GMT
- Organization: Netcom
- Message-ID: <311a98e8.87171105@nntp.ix.netcom.com>
- References: <30C40F77.53B5@swsbbs.com> <4d2ok0$69s@beach.and.nl> <4er2qo$h2s@galaxy.ucr.edu> <31118641.6802368@nntp.ix.netcom.com> <4eurpq$b75@news.xmission.com> <31137427.133220928@nntp.ix.netcom.com> <4f975g$g18@news.xmission.com> <31189e62.47294315@nntp.ix.netcom.com> <4fbs3n$31f@news.xmission.com>
- NNTP-Posting-Host: ix-dc17-06.ix.netcom.com
- X-NETCOM-Date: Thu Feb 08 5:10:10 PM PST 1996
- X-Newsreader: Forte Agent .99d/32.182
-
- tknarr@xmission.com ( Todd Knarr ) wrote:
-
- > In <31189e62.47294315@nntp.ix.netcom.com>, miker3@ix.netcom.com (Mike Rubenstein) writes:
- > >Just as it requires a conversion to be done for (char) 256, even if
- > >char is 8 bits. Again, the standard says a cast does a conversion and
- > >this is the correct syntax and valid data for the operation. Hence a
- > >conversion must be done.
- >
- > Except that you don't have legal data. 256 is not a legal value for a
- > char on machines with an 8-bit char. The question is whether the standard
- > defines "result" to mean only ( essentialy ) return value or whether it
- > includes outcomes in general.
-
- Of course you have legal data. The standard says you have legal data.
- The fact that you don't like it doesn't make it illegal.
-
- >
- > The reference section of K&R2 isn't the standard, but it tends to use
- > the same language as the standard and it refers to the result of / when
- > the second operand is 0 being undefined, and I know many conforming
- > compilers cause the program to terminate when you divide by 0, so if
- > you're right then K&R2 and the standard use different definitions and
- > I haven't seen that to be the case before.
-
- There's more to the standard than that section. The definition of
- implementation behavior says that it behavior can only occur for "a
- correct program construction and correct data ..." (ISO 3.10)
-
- Are you going to claim that what the standard calls "correct data" is
- somehow illegal? It's going to be very hard to convince me of that.
-
- Frankly, I'm beginning to wonder about you. Why quote K&R2 when
- there's a standard? If you don't have access to a copy, why not get
- it and read it before deciding what it says?
-
- What does the result of dividing by 0 have to do with anything. Why
- assume that what K&R2 say is the same as what the standard says. Why
- not look at the standard. You might learn that it does not use that
- wording for division by 0. It says (ISO 6.3.5)
-
- In both operations [/ and %], if the value of the second
- operand is zero, the behavior is undefined.
-
- Do you see the word "result" in that sentence?
-
- If you're going to claim that the standard uses the word result as
- meaning behavior in general, please cite the standard, not some book
- that you imagine uses the same words.
-
- It's clear from the standard that if a program attempts to divide by
- 0, it may do anything and the implementor is not required to document
- what it does.
-
-
- Michael M Rubenstein
-